2 Problem: 270 - Lining up
3 Andrés Mejía-Posada (andmej@gmail.com)
28 #define D(x) cout << #x " is " << x << endl
32 point(int x
=0, int y
=0) : x(x
), y(y
) {}
35 inline void simplify(pair
<int, int> &p
){
46 int sign
= ((p
.x
<0)^(p
.y
<0) ? -1 : 1);
47 if (p
.x
< 0) p
.x
*= -1;
48 if (p
.y
< 0) p
.y
*= -1;
49 int g
= __gcd(p
.x
, p
.y
);
50 if (g
) p
.x
/= g
, p
.y
/= g
;
60 fgets(buf
, 512, stdin
);
61 sscanf(buf
, "%d", &cases
);
62 fgets(buf
, 512, stdin
);
65 while (fgets(buf
, 512, stdin
) != NULL
&& strcmp(buf
, "\n")){
67 sscanf(buf
, "%d %d", &_
.x
, &_
.y
);
72 map
<pair
<int, int>, int> cnt
;
73 const int n
= p
.size();
74 for (int i
=0; i
<n
; ++i
){
75 for (int j
=i
+1; j
<n
; ++j
){
76 pair
<int, int> slope(p
[j
].y
- p
[i
].y
, p
[j
].x
- p
[i
].x
);
78 x
= max(x
, ++cnt
[slope
]);
82 printf("%d\n", (int)((1 + sqrt(1 + 8*x
))/2));
83 if (cases
> 0) puts("");